<?php	
define('_file_','edit_article');
if ( !isGod() )
	if ( !getRights($mod,'full') )
		if ( !News_getAccessFile(_file_) )
		{
			showMsg('Không có quyền truy cập vào trang này này !','ex','center');
			die();
		}
	$tid = getVar('tid',true);
	$aid = getVar('aid',true);
	$answer = getVar('ans');

	if ( empty($tid) || empty($aid) || $tid <= 0 || $aid <= 0 )
		die('Dữ liệu không hợp lệ !');

	$sql = "SELECT * FROM pctroubleshooting_topic WHERE Id=$tid";
	$rs = $link->execute($sql);
	$tname = $rs->fields('tname_vn');

	$sql = "SELECT * FROM pctroubleshooting_article WHERE Id=$aid AND tid=$tid";
	$rs = $link->execute($sql);
?>
<script language="javascript">
function ValidateForm()
{
	var obj = document.all['frmEditArticle'];
	if ( obj.txtTitle.value == "" )
	{
		alert('Chua nhap vao tieu de cua ban tin !');
		obj.txtTitle.focus();
		return false;
	}
	
	if ( obj.txtSContent.value == "" )
	{
		alert('Chua nhap vao noi dung thu gon cua ban tin !');
		obj.txtSContent.focus();
		return false;
	}

	if ( obj.txtFContent.value == "" )
	{
		alert('Chua nhap vao noi dung chi tiết cua ban tin !');
		obj.txtSContent.focus();
		return false;
	}
	
	if ( obj.txtDatePost.value == "" )
	{
		alert('Chua nhap vao ngay dang tin !');
		obj.txtDatePost.focus();
		return false;
	}

	return true;
}
</script>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>

<form action="admin.php?mod=<?= $mod ?>&act=process_edit_article" method="post" name="frmEditArticle"  enctype="multipart/form-data" onSubmit="return ValidateForm();">
  <table width="98%"  border="0" cellspacing="1" cellpadding="0" class="clsMyBorder">
    <tr>
      <td colspan="2" height="23" bgcolor="#336699" class="clsTitle">&nbsp;<img src="images/add_trans.gif" border="0" align="absmiddle" /> Hiệu chỉnh bài viết <font color="#FFFF00">[Bài viết thuộc chủ đề:
        <?= $tname ?>
        ]</font></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2">&nbsp;<font color="#000066"><i>* Những dòng có dấu (*) là dòng phải nhập vào nội dung </i></font></td>
    </tr>
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td height="21" colspan="2" bgcolor="#FF9900">&nbsp;<strong>Vietnamese </strong></td>
    </tr>
    <tr>
      <td valign="top" bgcolor="#F5F5F5">&nbsp;Câu hỏi <span class="style1">(*)</span> </td>
      <td bgcolor="#F5F5F5"><textarea name="txtQVN" cols="70" rows="5" id="txtQVN" style="background-color: #FFFFCC"><?= $rs->fields('question_vn') ?></textarea></td>
    </tr>
    <tr>
      <td valign="top">&nbsp;Trả lời <span class="style1">(*)</span> </td>
      <td valign="top"><textarea name="txtAVN" cols="70" rows="5" id="txtAVN" style="background-color: #FFFFCC"><?= $rs->fields('answer_vn') ?></textarea></td>
    </tr>
    <tr>
      <td height="21" colspan="2" bgcolor="#FF9900">&nbsp;<strong>English</strong></td>
    </tr>
    <tr>
      <td valign="top" bgcolor="#F0F0F0">&nbsp;Câu hỏi</td>
      <td bgcolor="#F0F0F0"><textarea name="txtQEN" cols="70" rows="5" id="txtQEN" style="background-color: #FFFFCC"><?= $rs->fields('question_en') ?></textarea></td>
    </tr>
    <tr>
      <td valign="top">&nbsp;Trả lời</td>
      <td valign="top"><textarea name="txtAEN" cols="70" rows="5" id="txtAEN" style="background-color: #FFFFCC"><?= $rs->fields('answer_en') ?></textarea></td>
    </tr>
    <tr>
      <td height="21" colspan="2" align="left" valign="middle" bgcolor="#FF9900"><strong>&nbsp;Thông tin khác </strong></td>
    </tr>
    <tr>
      <td bgcolor="#F0F0F0">&nbsp;Ngày hỏi <span class="style1">(*)</span> </td>
      <td bgcolor="#F0F0F0"><input name="txtNgayQ" type="text" id="txtNgayQ" size="30"class="vsinput"  maxlength="10" readonly="true" value="<?= _vnDate($rs->fields('question_date')) ?>" />
          <img src="images/lich.gif" width="16" height="16" border="0" align="absmiddle" onclick="c1.popup('txtNgayQ')" style="cursor:hand" /></td>
    </tr>
    <tr>
      <td>&nbsp;Ngày trả lời </td>
      <td><input name="txtNgayA" type="text" id="txtNgayA" size="30" maxlength="10"class="vsinput"  readonly="true" value="<?= _vnDate($rs->fields('answer_date')) ?>" />
          <img src="images/lich.gif" width="16" height="16" border="0" align="absmiddle" onclick="c1.popup('txtNgayA')" style="cursor:hand" /></td>
    </tr>
    <tr>
      <td bgcolor="#F0F0F0">&nbsp;Người hỏi <span class="style1">(*)</span> </td>
      <td bgcolor="#F0F0F0"><input name="txtNguoiQ" type="text" id="txtNguoiQ" size="50"class="vsinput"  maxlength="50" value="<?= $rs->fields('questioner') ?>" /></td>
    </tr>
    <tr>
      <td>&nbsp;Người trả lời </td>
      <td><input name="txtNguoiA" type="text" id="txtNguoiA" size="50" maxlength="50"  class="vsinput" value="<?= $rs->fields('answerer') ?>"/></td>
    </tr>
    <tr>
      <td bgcolor="#F0F0F0">&nbsp;Email người hỏi <span class="style1">(*)</span> </td>
      <td bgcolor="#F0F0F0"><input name="txtEmailQ" type="text" id="txtEmailQ" size="50" class="vsinput" maxlength="50"  value="<?= $rs->fields('email_questioner') ?>" /></td>
    </tr>
    <tr>
      <td>&nbsp;Email người trả lời </td>
      <td><input name="txtEmailA" type="text" id="txtEmailA" size="50" maxlength="50" class="vsinput" value="<?= $rs->fields('email_answerer') ?>" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" align="right" bgcolor="#000066" class="clsPanelButton"><input name="cmdOK" type="submit" value="Cập nhật &raquo;" />
        &nbsp;</td>
      <input type="hidden" name="hidAid" value="<?= $aid ?>" />
	  <input type="hidden" name="hidAns" value="<?= $answer ?>" />
      <input type="hidden" name="hidTid" value="<?= $tid ?>" />
    </tr>
  </table>
<script language="javascript1.2">
editor_generate('txtAVN');
editor_generate('txtAEN');
editor_generate('txtQVN');
editor_generate('txtQEN');
</script>
</form>
<?php
function _vnDate($dt)
{
	return substr($dt,8,2) . '/' . substr($dt,5,2) . '/' . substr($dt,0,4);
}

?>
